package cn.doitedu.demos

import scala.collection.mutable.ListBuffer

object ArraySlice {

  def main(args: Array[String]): Unit = {
    val arr = Array("e1","e3","e1","e5","e6","e3","e6")
    println(arr.slice(0, 2).toList)
    println(arr.reverse.slice(0, 3).toList)

    sys.exit()

    val idx = for(i<- 0 until arr.size) yield {
      if(arr(i).equals("e6")) i else -1
    }
    println(idx.toList.filter(_ > 0))



  }

  /*def cut(arr:Array[String],segments : ListBuffer[Array[String]]) = {
    val i = arr.indexOf("e6")
    val tuple = arr.splitAt(i + 1)
    segments += tuple._1
    if(tuple._2.size>0 && tuple._2.contains("e6")){
      cut(tuple._2,segments)
    }else if(tuple._2.size>0){
      segments += tuple._2
    }
    segments
  }*/

}
